module.exports = `
<template>
<div class="login">
  <div class="login-box">
    <div class="header">
      <div class="title">
        <span class="text">{{{loginTitle}}}</span>
        <span class="triangle"></span>
      </div>
    </div>
    <div class="content">
      <input
        class="username input"
        v-model="username"
        @keyup.enter="handleSubmit"
        type="text"
        placeholder="请输入账号"
      />
      <input
        class="password input"
        type="password"
        v-model="password"
        @keyup.enter="handleSubmit"
        placeholder="请输入密码"
      />
      <div class="verify-code-box">
        <div class="input-box">
          <input
            class="password input"
            v-model="imageCode"
            type="text"
            placeholder="请输入验证码"
            @keyup.enter="handleSubmit"
          />
        </div>
        <div class="code-box" @click="refreshVerifyCode">
          <img :src="imgCodeUrl" alt="验证码" />
        </div>
      </div>
    </div>
    <div class="option">
    <div class="btn-wrap">
    <!--
      <div class="register-btn" @click="handleJumpRegister">注册</div>
      -->
    </div>
    <div class="login-submit-btn" @click="handleSubmit">登录</div>
  </div>
  </div>
</div>
</template>

<script>
//API
// import APIS from "@/utils/api_config";

import jhTools from "@/utils/jhTools"; //工具函数

//公共函数 含封装的请求函数
import API from "@/utils/api_config.js";

export default {
name: "login",
data() {
  return {
    username: "",
    password: "",
    imageCode: "",
    imgCodeUrl: {{{verifyCodeApi}}},
    allMethods: {}, //方法抽离
  };
},
mounted() {
  this.allMethods = this.getAllMethods();
},
methods: {
  //注册跳转
  handleJumpRegister() {
    this.$router.push({
      path: "/register",
      name: "register",
    });
  },

  //刷新验证码
  refreshVerifyCode() {
    this.imgCodeUrl = "";
    setTimeout(() => {
      this.imgCodeUrl = {{{verifyCodeApi}}};
    });
  },

  //登录
  handleSubmit() {
    // console.log("click");
    //组合
    let url = {{{loginApi}}}
    let data = {
      accountNo: this.username,
      pwd: this.password,
      imageCode: this.imageCode,
    };
    var dataRes = jhTools.checkInputTool({
      tThis: this,
      dataArr: ["username", "password", "imageCode"],
      tipsObj: {
        username: "请输入用户名",
        password: "请输入密码",
        imageCode: "请输入验证码",
      },
    });
    if (!dataRes) return;

    console.log("登录提交", data);
    //请求
    this.$http
      .post(url, data, { "Content-Type": "multipart/form-data" })
      .then(
        //请求成功
        (res) => {
          let data = res.data;
          console.log("登录成功", res.data);
          if (res.data.message == "操作成功") {
            // 保存 token 账号，用户id，菜单
            sessionStorage.setItem("sessionId", data.data.sessionId); //sessionId
            sessionStorage.setItem("loginName ", data.data.loginName); //用户登录名
            sessionStorage.setItem("userId", data.data.id); //id字段
            // sessionStorage.setItem("menus", JSON.stringify(data.data.menus));
            // 提示
            this.$message({
              type: "success",
              message: "登陆成功！",
            });
            //跳转
            this.$router.push({
              path: "/index",
              name: "index",
            });
            // this.$router.replace({ path: "/" });

            //刷新
            this.$router.go(0);
          } else {
            //错误提示
            this.$message({
              type: "warning",
              message: data.message,
            });
          }
        },
        //请求失败
        (err) => {
          console.log(err);
        }
      );
  },

  /* 方法抽离集合 */
  getAllMethods() {
    var _this = this;
    return {
      
    };
  },
},
};
</script>

<style lang="scss" scoped>
// @import '~styles/mixins.scss';
// @import '~styles/variables.scss';

//登录
.login {
width: 100%;
height: 100%;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
}

.login-box {
width: 421px;
min-height: 498px;
line-height: 20px;
border-radius: 4px;
text-align: center;
border: 1px solid rgba(219, 215, 219, 1);
.header {
  position: relative;
  height: 144px;
  border-width: 0;
  .title {
    position: absolute;
    left: -20px;
    top: 50px;
    width: 409px;
    height: 60px;
    line-height: 20px;
    border-radius: 1px;
    background-color: #4e6ef2;
    text-align: center;
    .text {
      position: absolute;
      top: 17px;
      left: 60px;
      min-width: 60px;
      height: 30px;
      line-height: 30px;
      color: rgba(255, 255, 255, 1);
      font-size: 18px;
      text-align: center;
      font-family: Roboto;
    }
    .triangle {
      position: absolute;
      bottom: -20px;
      left: -1px;
      width: 0;
      height: 0;
      border: 10px solid transparent;
      border-top-color: rgba(106, 122, 153, 1);
      border-right-color: rgba(106, 122, 153, 1);
    }
  }
}

.content {
  .input {
    padding-left: 20px;
    width: 343px;
    height: 53px;
    border-radius: 4px;
    color: rgba(136, 136, 136, 1);
    font-size: 14px;
    text-align: left;
    font-family: Roboto;
    border: 1px solid rgba(222, 222, 222, 1);
    box-sizing: border-box;
    outline-color: #ccc;
  }

  .password {
    margin-top: 20px;
  }
}
}

// 验证码
.verify-code-box {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
// justify-content: space-between;
.input-box {
  width: 250px;
  margin-left: 40px;

  input {
    width: 100%;
  }
}

.code-box {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 20px;
  margin-left: 10px;
}
}

.option {
  position: relative;
  height: 124px;

  .register-btn {
    position: absolute;
    top: 21px;
    left: 50px;
    width: 100%;

    color: rgba(9, 126, 242, 1);
    font-size: 14px;
    font-family: SourceHanSansSC-regular;
    width: 30px;
    height: 26px;
    cursor: pointer;
  }

  .login-submit-btn {
    position: absolute;
    top: 52px;
    left: 38px;
    width: 344px;
    height: 55px;
    line-height: 55px;
    border-radius: 4px;
    background-color: #4e6ef2;
    color: rgba(255, 255, 255, 1);
    font-size: 18px;
    text-align: center;
    font-family: Roboto;
    border: 1px solid rgba(222, 222, 222, 1);
    cursor: pointer;
    opacity: 0.9;
  }

  .login-submit-btn:hover {
    opacity: 1;
  }
}
</style>
`